import React, { Component } from 'react'
import PropTypes from 'proptypes'
import { connect } from 'react-redux'
import { fetchThreadList } from '../../actions/index'

class SearchList extends Component {
    componentWillMount () {
        this.props.fetchThreadList(this.props.location.query.q)
    }
    componentWillReceiveProps (props) {
        console.log(props.params, props, '<--------')
        if (this.props.location.query.q !== props.location.query.q) {
            this.props.fetchThreadList(this.props.location.query.q)
        }
    }
    render () {
        return (
            <div>
                search result
            </div>
        )
    }
}

function mapStateToProps (state) {
    return {}
}
function mapDispatchToProps (dispatch) {
    return {
        fetchThreadList: (filter) => dispatch(fetchThreadList(filter))
    }
}
export default connect(mapStateToProps, mapDispatchToProps)(SearchList);
